package mpc;

import java.io.*;
import java.util.*;

public class Reader {
	private BufferedReader in;
	private StringTokenizer st;
	private String skipped;
	
	public Reader(File file) throws IOException{
		in = new BufferedReader(new FileReader(file));
		st = new StringTokenizer(in.readLine());
	}
	
	public int nextInt() throws IOException{
		if (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
		return Integer.parseInt(st.nextToken());
	}
	
	public double nextDouble() throws IOException{
		if (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
		return Double.parseDouble(st.nextToken());
	}
	
	public String nextWord() throws IOException{
		if (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	public void skipWord(int n) throws IOException{
		for(int i = 0; i < n; i++){
			skipped = this.nextWord();
		}
	}
	
	public boolean hasNext() throws IOException{
		if (st.hasMoreTokens()) return true;
		String s = in.readLine();
		if(s == null) return false;
		st = new StringTokenizer(s);
		return true;
	}
	
	public void close() throws IOException{
		in.close();
	}
}
